layui.use(['jquery','table','laydate'],function(){
    var $=layui.jquery;
    var table=layui.table;
    var laydate=layui.laydate;

    laydate.render({
        elem: '#createTime',
        type: 'datetime',
        trigger: 'click'
    })

    demoTable();

    refresh=function refresh(){
        location.reload();
    }

    getTable('','','','');

    function getTable(dictLabel,dictValue,createTime){
        $.ajax({
            url:"/SyDictData/getProductPrice",
            type:"post",
            dataType:"json",
            data:{'dictLabel':dictLabel,'dictValue':dictValue,'createTime':createTime},
            success:function (data) {
                demoTable(data.data);
            }
        })
    }

    search=function search(){
        var dictLabel=$("input[name=dictLabel]").val();
        var dictValue=$("input[name=dictValue]").val();
        var createTime=$("input[name=createTime]").val();
        getTable(dictLabel,dictValue,createTime);
    }

    /*表格*/
    function demoTable(data){
        table.render({
            elem:'#demoTable',
            title:"历史价格详情",
            data:data,
            toolbar:'#button_ids',
            limit:5,
            width:1620,
            page:{
                layout:['count','prev','page','next','limit','skip','refresh'],
                limits:[5,10,20],
                first:"首页",
                last:"尾页",
            },
            cols:[[
                {type:'checkbox'},
                {title:"序号",align:'center',width:114,templet:function(data){
                        return data.LAY_INDEX;
                    }},
                {field:"dictLabel",title:"商品编号",align:'center',width:290},
                {field:"dictValue",title:"商品名称",align:'center',width:290},
                {field:"cssClass",title:"原价",align:'center',width:290},
                {field:"listClass",title:"现价",align:'center',width:290},
                {field:"createTime",title:"操作时间",align:'center',width:290},
            ]]
        })
    }

    //返回按钮
    $('#goBack').click(function () {
        var title = $('#title').text();
        var iframe = parent.$('.iframe');
        $.each(iframe,function (i,item) {
            if(title == $(item).attr('_href')){
                parent.$('#beforeHref').val($(item).attr('_href'));
                parent.beforeHref();
                return;
            }
        });
    });

})